<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>常规检</title>
		<!-- 页面样式 -->
		<link rel="stylesheet" href="./assets/css/QMS/PageCss/DocumentsPage.css">
		<link rel="stylesheet" href="./assets/css/QMS/luckysheet/pluginsCss.css">
		<link rel="stylesheet" href="./assets/css/QMS/luckysheet/luckysheet.css">
		<link rel="stylesheet" href="./assets/css/QMS/luckysheet/plugins.css">
		<link rel="stylesheet" href="./assets/css/QMS/luckysheet/iconfont.css">
		<!-- <link rel="stylesheet" href="http://at.alicdn.com/t/c/font_4096975_i8f4jjygw.css"> -->
		<link rel="stylesheet" href="./assets/css/QMS/vant.min.css">
		<link rel="stylesheet" href="./assets/css/QMS/element.css">
		<!-- 引入 Handsontable 用到的 polyfill -->
		<!-- <script src="https://cdn.jsdelivr.net/npm/@babel/polyfill/dist/polyfill.min.js"></script> -->

		<!-- 引入 Handsontable -->
		<!-- <link rel="stylesheet" href="https://unpkg.com/handsontable/dist/handsontable.full.min.css"> -->
		<script src="./assets/script/my-xmlhttprequest.js"></script>
		<script src="./assets/script/jquery.js"></script>
		<script src="./assets/script/vue.min.js"></script>
		<!-- <script src="../../../static/assets/script/layer/layer.js"></script> -->
		<script src="./assets/script/layer/mobile/layer.js"></script>
		<script src="./assets/script/vant.min.js"></script>
		<script src="./assets/script/element.js"></script>
		<script src="./assets/script/plugin.js"></script>
		<script src="./assets/script/umd.js"></script>
		<script src="./assets/js/base.js"></script>

		<style>
			body,
			html,
			#app {
				height: 100vh;
			}

			.toast {
				position: absolute;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -150%);
				padding: 5px 10px;
				background-color: rgba(0, 0, 0, 0.6);
				color: #fff;
				font-size: 16px;
				opacity: 0;
				border-radius: 20px;
				transition: opacity 0.5s;
			}

			.toast.animate {
				opacity: 1;
				transform: translate(-50%, -200%);
				animation: toast-move 1s;
			}

			@keyframes toast-move {
				0% {
					transform: translate(-50%, -200%);
				}

				50% {
					transform: translate(-50%, -250%);
				}

				100% {
					transform: translate(-50%, -300%);
				}
			}

			/* 自定义的详情展示层 */
			.RowInfoBox {
				width: 40vw;
				height: 60vh;
				overflow: hidden;
				background-color: #fcfcfc;
				border-radius: 12px;
				z-index: 1999;
				position: absolute;
				left: 0;
				bottom: 60px;
				box-shadow: 0px 0px 11px -6px #333333;
				display: flex;
				flex-direction: column;
			}

			.RowInfoBox .topNav {
				border-bottom: 1px solid #999;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 10px 15px;
			}

			.RowInfoBox .MainBox {
				flex: 1;
				overflow-y: auto;
				display: flex;
				justify-content: space-between;
			}

			.RowInfoBox .InfoMain {
				position: relative;
				width: 100%;
				overflow-y: auto;
				/* padding: 10px 15px; */
			}
		</style>
	</head>

	<body>
		<div id="app" v-cloak>
			<div style="padding-top: 20px;">
				<van-nav-bar title="常规检" left-arrow @click-left="onClickLeft">
					<template #right>
						<!-- <van-button size="mini" type="info" plain style="margin-right: 8px;"
						@click="OpenAddInspection">增加检验次数</van-button> -->

						<van-icon name="plus" size="26" color="#333" @click="OpenInspectionData"></van-icon>

						<div style="margin-left: 6px;">
							<el-dropdown trigger="click">
								<div style="display: flex;align-items: center;">
									<van-icon name="apps-o" size="26" color="#333"></van-icon>
								</div>

								<el-dropdown-menu slot="dropdown">
									<el-dropdown-item>
										<div @click="OpenListPopup">
											<span>历史单据</span>
										</div>
									</el-dropdown-item>
									<el-dropdown-item>
										<div @click="OpenControl">
											<span>切换设备</span>
										</div>
									</el-dropdown-item>
									<!-- <el-dropdown-item>
									<div @click="OpenAddInspection">
										<span>增加检验次数</span>
									</div>
								</el-dropdown-item> -->
									<el-dropdown-item>
										<div @click="OpenRowInfo">
											<span>{{RowInfo.AllowToShow ? '关闭':'开启'}}详情弹层</span>
										</div>
									</el-dropdown-item>
								</el-dropdown-menu>
							</el-dropdown>
						</div>
					</template>
				</van-nav-bar>
			</div>


			<!-- luckysheet容器 -->
			<div id="luckysheet"></div>

			<div class="bottom">
				<div class="buttonBox" :style="{'z-index' : !showEditWindow ? '999' : '9'} ">
					<div class="BottomLeft">
						<div class="StatusBox" v-if="DeviceInfo.ShowDeviceType && DeviceInfo.DeviceModel == '游标卡尺'"
							@click="SendMessage('message')">
							<div class="deviceStatus" :style="{'background-color': deviceStatus ? '#17d56b':'#999'}">
							</div>
							<span class="StatusText"
								:style="{'color': deviceStatus ? '#17d56b':'#999'}">{{ deviceStatus ? '已连接' : '未连接' }}</span>
						</div>

						<div style="margin-left: 16px;font-size: 12px;"
							:style="{color: DeviceInfo.NeedDevice == DeviceInfo.DeviceModel ? '#3bc201' : '#999'}">
							<div>
								<span>所需设备：{{Choice_In_ListInfo.Benchmark}}</span>
							</div>

							<div>
								<span>测量设备：{{DeviceInfo.DeviceModel}}</span>
							</div>
						</div>

						<div class="theCJQty" style="margin-left: 16px;font-size: 14px;color: #999;">
							<div>
								<span
									v-show="Choice_In_ListInfo.ShowCJQty">最大检验数：{{Choice_In_ListInfo.RowActualCJQty}}</span>
							</div>
						</div>

					</div>


					<div class="btnBox" v-show="originData.mainData.RoutineInspectionID">
						<van-button :type="originData.mainData.Approve == '未审核' ? 'primary' : 'danger'"
							v-if="ApproveBack(originData.mainData.ApproveID == 1 ? '反审核' : '审核')" @click="ApproveBtn"
							style="margin-right:8px;">{{ originData.mainData.Approve == '未审核' ? '审核' : '反审核'}}</van-button>
						<van-button v-if="ApproveBack('提交')" type="info" @click="SubmitBtn">提交</van-button>
					</div>
				</div>

				<!-- <van-search id="IPT" ref="editKeyControl" v-model="editKeyword" background="#fff" left-icon=""
					@blur="BlurSearch" :inputmode="InputFocus" @search="submitKeyword(editKeyword)" show-action="true">
					<div slot="action" style="color:green;font-size:25px;" @click="submitKeyword(editKeyword)">
						<van-icon name="checked" />
					</div>
				</van-search> -->

				<div class="searchBox" ref="editKeyControl" :style="{'z-index' : showEditWindow ? '999' : '9'} "
					style="display: flex;align-items: center;justify-content: space-between;">
					<input :inputmode="InputFocus" type="text" class="IptStyle" id="autoInput" @blur="BlurSearch"
						@keydown.enter.prevent="submitKeyword" />

					<van-button class="confirmBtn" type="primary" size="small" @click="submitKeyword">确定</van-button>
				</div>
			</div>


			<!-- 点击luckysheet 打开详情弹层 -->
			<div class="RowInfoBox" v-show="RowInfo.ShowRowInfo && RowInfo.AllowToShow">
				<div class="topNav">
					<span>检验项明细</span>
					<van-icon name="cross" size="20" @click="CloseRowInfo"></van-icon>
				</div>

				<div class="MainBox">
					<div class="InfoMain">
						<van-button style="position: absolute;right: 10px;top: 10px;z-index: 99;" type="info"
							size="mini" @click="ToggleUnfold">{{ToUnfold ? '< 闭合实测值':'展开实测值 >'}}</van-button>

						<van-field :value="ChoiceRowInfo.ProductName" label="产品名称" readonly></van-field>
						<!-- <van-field :value="ChoiceRowInfo.ProcedureName" label="工序" readonly></van-field> -->
						<van-field :value="ChoiceRowInfo.FQCItemName" label="检验项目" readonly></van-field>
						<van-field :value="ChoiceRowInfo.JYBZ" label="检验标准" readonly></van-field>
						<van-field :value="Choice_In_ListInfo.RowCJQty" label="抽检数量" readonly></van-field>
						<van-field :value="Choice_In_ListInfo.RowActualCJQty" label="实际抽检" readonly></van-field>

						<van-field :value="ChoiceRowInfo.FResult" label="检验结果" readonly is-link
							@click="showResult = true"></van-field>
						<van-field :value="ChoiceRowInfo.FRemarks" label="备注" readonly></van-field>
						<van-field :value="ChoiceRowInfo.NewTime" label="检验时间" readonly></van-field>
					</div>

					<div class="InfoMain" v-show="ToUnfold">
						<van-field v-for="(item,index) in TheValueData" :key="index" :value="item.value"
							:label="`第 ${index + 1} 项:`" readonly placeholder="（无)"
							@click="ChoiceWhere(item,index)"></van-field>
					</div>

				</div>
			</div>

			<!-- 子表表格检验弹层 -->
			<van-popup v-model="showResult" @close="closeJYResult" style="min-width: 280px;">
				<van-nav-bar left-text="检验结果"></van-nav-bar>

				<van-radio-group v-model="isJYResult">
					<van-cell-group>
						<van-cell title="合格" clickable @click="showResult = false;isJYResult = '合格'">
							<template #right-icon>
								<van-radio name="合格" />
							</template>
						</van-cell>
						<van-cell title="不合格" clickable @click="showResult = false;isJYResult = '不合格'">
							<template #right-icon>
								<van-radio name="不合格" />
							</template>
						</van-cell>
						<van-cell title="忽略" clickable @click="showResult = false;isJYResult = '忽略'">
							<template #right-icon>
								<van-radio name="忽略" />
							</template>
						</van-cell>
					</van-cell-group>
				</van-radio-group>
			</van-popup>

			<!-- 列表弹窗 -->
			<van-popup v-model="showListBox" round :close-on-click-overlay="false" :style="{ width:'90%',zoom:'1' }">
				<!-- FirstInspectionID -->
				<van-cell title="常规检">
					<template #default>

						<div style="display: flex;align-items: center;justify-content: flex-end;">
							<van-icon v-if="originData.mainData.RoutineInspectionID" name="cross" size="20"
								@click="showListBox = false"></van-icon>

							<span v-else @click="onClickLeft">退出</span>
						</div>
					</template>
				</van-cell>

				<!-- 列表 -->
				<div class="PopupTabsBox">

					<div class="RefreshIcon">
						<van-icon @click="RefreshTables" name="replay" size="20"></van-icon>
					</div>

					<el-tabs type="border-card" v-model="active">
						<el-tab-pane label="检验列表">
							<div style="position: relative;">

								<el-table ref="TableList" v-loading="NotTableLoading" :stripe="true"
									:data="NotListTableData" style="width: 100%" :height="MinNums"
									@cell-click="ChoiceTableCell">
									<el-table-column align="center" fixed type="index" width="50" :resizable="false"
										label="序号">
										<template slot-scope="scope">
											{{(NotPage.pageDocumentPage - 1) * NotPage.pageSize + scope.$index + 1}}
										</template>
									</el-table-column>
									<el-table-column align="center" prop="Approve" label="审核状态" width="100">
										<template slot-scope="scope">
											<el-tag size="mini" v-if="scope.row.Approve == '已审核'"
												type="success">已审核</el-tag>
											<el-tag size="mini" v-else type="info">未审核</el-tag>
										</template>
									</el-table-column>
									<el-table-column align="center" prop="BillNO" label="单据编号">
									</el-table-column>
									<el-table-column align="center" prop="BillDate" label="单据日期">
									</el-table-column>
									<el-table-column align="center" prop="SXJDate" label="检验时间段">
									</el-table-column>
									<el-table-column align="center" prop="Creater" label="制单人">
									</el-table-column>
									<el-table-column fixed="right" label="操作" width="100">
										<template slot-scope="scope">
											<el-button type="text" size="small"
												@click="TableViewBtn(scope.row)">查看</el-button>
										</template>
									</el-table-column>
								</el-table>

								<!-- 新增按钮 -->
								<van-icon size="40" color="#fff" @click="AddInspectionBtn"
									style="position: absolute;bottom: 15px;right: 4px;z-index: 999;background-color: #78d5ff;border-radius: 50%;"
									name="add-o"></van-icon>
							</div>
							<!-- 分页 -->
							<div class="PageBox">
								<div class="PageLeftBox">
									<span>总数：</span>
									<span>{{NotTotal}}</span>

									<span style="margin-left: 10px;">每页</span>
									<span>{{NotPage.pageSize}}</span>
									<span> 条</span>

								</div>

								<div class="PageRightBox">
									<van-pagination v-model="NotPage.pageIndex"
										:page-count="Math.ceil(NotTotal/NotPage.pageSize)" mode="simple"
										@change="ChangePageIndex(0)"></van-pagination>
								</div>

							</div>
						</el-tab-pane>
					</el-tabs>

				</div>


				<!-- 点击历史单据列表 - 未检验 - 新增按钮 -->
				<!-- 添加z-index 避免弹层层级不够，出现样式问题 -->
				<van-popup v-model="ShowAddInspection" :duration="0" style="z-index: 9999;"
					:style="{ width:'100%' ,height: '100%'}">
					<div class="AddPopup">

						<van-nav-bar>
							<template #left>
								<div @click="CloseAddPopup" v-if="!IsOpenInspectionData">
									<van-icon name="arrow-left" size="24"></van-icon>
									<span>新增编辑检验</span>
								</div>
							</template>

							<template #right>
								<van-icon name="scan" size="24" @click="ToScan" style="margin-right: 12px;"></van-icon>

								<div @click="CloseAddDataPopup" v-if="IsOpenInspectionData">
									<van-icon name="cross" size="24"></van-icon>
								</div>
							</template>
						</van-nav-bar>


						<el-tabs type="border-card" v-model="AddEditActive" class="AddTabPopup" style="height: 100%;">
							<el-tab-pane v-if="!IsOpenInspectionData" label="检验产品表" name="0">
								<span slot="label">
									检验产品表
									<el-tag type="success" size="mini"
										v-if="AddListTableData.length">{{AddListTableData.length}}</el-tag>
								</span>
								<el-table :stripe="true" :data="AddListTableData" style="width: 100%" :height="MinNums">
									<el-table-column align="center" fixed type="index" width="50" :resizable="false"
										label="序号"></el-table-column>
									<el-table-column align="center" prop="ProductName" label="产品名称" width="200">
									</el-table-column>
									<el-table-column align="center" prop="JYLX" label="检验类型" width="80">
									</el-table-column>
									<el-table-column align="center" prop="ProcedureName" label="工序" width="200">
									</el-table-column>
									<el-table-column align="center" prop="AQL" label="抽样方案" width="200">
									</el-table-column>
									<el-table-column align="center" prop="CJQty" label="抽检数量" width="80">
									</el-table-column>
									<el-table-column align="center" prop="ReceiveNum" label="接收数量" width="80">
									</el-table-column>
									<el-table-column align="center" prop="RejectionNum" label="拒收数量" width="80">
									</el-table-column>
									<el-table-column v-show="AddListTableData.length" fixed="right" label="操作"
										width="100">
										<template slot-scope="scope">
											<el-button type="text" size="small"
												:disabled="scope.row.RoutineInspectionDeID != 0"
												@click="DeleteAddRow(scope.row)">删除</el-button>
										</template>
									</el-table-column>
								</el-table>

								<div class="ListBoxBottom" style="width: 100%;display: flex;align-items: center;">
									<div style="width: calc(100% - 80px);">
										<van-field class="Remarks" v-model="Add_RemarkData" label="备注"
											placeholder="可输入备注"></van-field>
									</div>

									<div style="min-width: 80px;">
										<van-button @click="AddSubmit" type="info" size="small">确认</van-button>
									</div>
								</div>
							</el-tab-pane>
							<el-tab-pane label="新增" name="1">
								<div class="AddPopup">

									<div class="AddPopupMainBox">
										<div class="FormBox">
											<van-field v-model="AddFormData.JYLX" label="检验类型" placeholder="请选择检验类型"
												readonly :error="Rule.JYLX" required @click="openBaseScreen('检验类型')"
												is-link></van-field>

											<van-field v-model="AddFormData.ProductName" label="品号" placeholder="请选择品号"
												readonly :error="Rule.ProductName" required
												@click="openBaseScreen('品号')" is-link></van-field>

											<van-field v-model="AddFormData.ProcedureName" label="工序"
												:placeholder="FormPlaceHolder ? '请选择工序' : '请先选择品号'" readonly required
												:error="Rule.ProcedureName" @click="openBaseScreen('工序')"
												is-link></van-field>

											<van-field v-model="AddFormData.BJNum" label="来料数量"
												:readonly="!FormPlaceHolder" @blur="GetCJQty"
												:placeholder="FormPlaceHolder ? '请输入来料数量' : '请先选择品号'" required
												:error="Rule.BJNum" type="number"></van-field>

											<van-field v-model="AddFormData.Fbatch" label="批次"
												:readonly="!FormPlaceHolder"
												:placeholder="FormPlaceHolder ? '请输入批次' : '请先选择品号'" required
												:error="Rule.Fbatch"></van-field>

											<van-field readonly v-model="AddFormData.ProductCode"
												label="品名"></van-field>
											<van-field readonly v-model="AddFormData.ProductSpec"
												label="规格"></van-field>
											<van-field readonly v-model="AddFormData.FMaterials" label="材质"></van-field>

											<van-field v-model="AddFormData.CJQty" label="抽检数量" readonly
												placeholder="请输入来料数量" type="number"></van-field>
											<van-field v-model="AddFormData.AQL" label="抽样方案" readonly
												placeholder="请输入来料数量" type="text"></van-field>
											<van-field v-model="AddFormData.ReceiveNum" label="接收数量" readonly
												placeholder="请输入来料数量" type="number"></van-field>
											<van-field v-model="AddFormData.RejectionNum" label="拒收数量" readonly
												placeholder="请输入来料数量" type="number"></van-field>

										</div>
									</div>

									<div class="PopupBottomSubBtn ListBoxBottom">
										<van-button @click="AppPushList" type="info"
											size="small">{{!IsOpenInspectionData ? '添加到产品表' : '新增'}}</van-button>

									</div>
								</div>
							</el-tab-pane>
						</el-tabs>

					</div>
				</van-popup>

			</van-popup>

			<!-- 筛选列表 -->
			<van-popup v-model="showBaseScreen" position="right" :style="{ height: '100%',width: '100%' }">
				<div style="display: flex;flex-direction: column;height: 100%;">
					<van-nav-bar class="head head-index" title="筛选" left-arrow
						@click-left="CloseBaseScreen"></van-nav-bar>

					<van-list style="flex: 1;overflow: auto;">
						<van-cell v-for="(item,index) in FilterList" :key="index" @click="ChoiceListCell(item)">
							<template #title>
								<span>{{item.name}}</span>
							</template>
						</van-cell>
					</van-list>
				</div>
			</van-popup>

			<!-- 增加抽检次数 -->
			<van-popup v-model="AddInspectionNum" :close-on-click-overlay="false" style="min-width: 320px;">
				<div>
					<van-nav-bar left-text="请填写检验次数"></van-nav-bar>

					<div class="PopupMain" style="min-height: 70px;padding: 12px 24px">
						<van-field style="border: 1px solid #333;border-radius: 12px;" v-model="InspectionNum"
							placeholder="请输入次数" type="number"></van-field>
					</div>

					<div class="bottomBtn"
						style="padding: 6px 8px;display: flex;justify-content: flex-end;align-items: center;">
						<van-button style="min-width: 70px;margin-right: 4px;" size="small" type="default"
							@click="CloseAddCloumnPopup">取消</van-button>
						<van-button style="min-width: 70px;" size="small" type="info"
							@click="AddInspection">确定</van-button>
					</div>
				</div>
			</van-popup>

			<!-- 加载 -->
			<van-overlay :show="showLoading" @click="showLoading = false" class="LoadingOverlay">
				<div class="wrapper" @click.stop>
					<div class="block">

						<div class="LoadingBox">
							<div class="TheLoading">
								<div class="spinner-6"></div>

							</div>
						</div>
						<span style="font-size: 24px;">加载中</span>
					</div>
				</div>
			</van-overlay>

		</div>
	</body>

	<!-- <script src="./MorkData.js"></script> -->
	<!-- <script src="./MorkData/LuckysheetData.js"></script> -->
	<!-- 调用 uniapp webview 的 api ，记得需要写在 body 标签下面 -->
	<script src="./assets/script/uni.webview.1.5.4.js"></script>
	<script type="text/javascript">
		var vm = new Vue({
			el: '#app',
			data: {
				showListBox: true, // 列表弹层
				active: 0, // 标签页
				MinNums: 250, // 单据列表表格高度
				NotPage: {
					pageIndex: 1,
					pageSize: 5,
					pageDocumentPage: 1,
				},
				PageIndexTimer: null, // 用于切换分页时的防抖
				NotListTableData: [], // 未报检列表数据
				NotTotal: null, // 未检验总数
				NotTableLoading: true, // 未检验表格弹窗loading
				IsPage: {
					pageIndex: 1,
					pageSize: 5,
					pageDocumentPage: 1,
				},
				IsListTableData: [], // 已检验
				IsTotal: null, // 已检验总数
				IsTableLoading: false, // 已检验表格弹窗loading

				RoutineInspectionID: '', // 选中列表的ID，有值就是从查看来的
				AddAllowBack: true, // 是否允许退出新增弹窗
				Add_RemarkData: '', // 新增编辑的备注弹层
				AddEditActive: '0', // 新增检验项Tab索引
				ShowAddInspection: false, // 列表新增弹层
				IsOpenInspectionData: false, // 初始化后，点击新增的弹层
				AddListTableData: [], // 新增-添加的表格数据
				FormPlaceHolder: false, // 新增弹层表单——品号是否存在
				AddFormData: { // 新增弹窗表单内容
					JYLX: '', // 检验类型
					JYLXID: '',

					ProcedureID: '', // 工序
					ProcedureCode: '',
					ProcedureName: '',

					ProductID: '', // 品号
					ProductName: '',
					ProductSpec: '', // 规格
					FMaterials: '', // 材质
					Fbatch: '', // 批次
					BJNum: '', // 来料数量
					CJQty: '', // 抽检数量
					AQL: '', // 抽样方案
					ReceiveNum: '', // 接收数量
					RejectionNum: '', // 拒收数量
				},
				Rule: { // 新增弹窗表单验证
					JYLX: false, // 检验类型
					ProductName: false, // 品号
					ProcedureName: false, // 工序
					BJNum: false, // 来料数量
					Fbatch: false, // 批次
				},
				showBaseScreen: false, // 显示筛选弹层
				SelectName: '', // 记录新增表单点击项
				FilterList: [], // 筛选弹层列表
				lastClickTime: 0, // 上一次函数被执行的时间
				throttleTime: 500, // 节流时间间隔

				showLoading: false, // 加载动画
				immersed: null, // 安全高度
				UserInfo: null, // 登录的用户信息
				deviceStatus: false, // 获取设备连接状态
				IsWhere: '', // 选中的单元格
				AllowableScope: { // 允许选中范围
					r: 0, // 行
					c: 4, // 列
				},
				editRange: [], // 单元格选中信息
				editKeyword: '', // 输入框的值
				InputFocus: 'none', // 输入框是否可弹起键盘
				showEditWindow: false, // 底部按钮层级，用于区分是否显示输入框
				SheetListData: [], // 表格内容
				ChoiceRowInfo: {}, // 选中单元格后，获取到的行信息
				Choice_In_ListInfo: {
					FirstIndex: 0, // 第一级的产品索引
					FQCItemsIndex: 0, // 产品下的第条数据的索引
					Benchmark: '', // 选中行需要的检验设备
					IsMeasured: false, // 选中项是否是实测值
					RowCJQty: 0, // 选中行的检验数量
					RowActualCJQty: 0, // 实际抽检数量
					ShowCJQty: false, // 选中行是否是检验行
				},
				DeviceInfo: {
					Communication: '', // 协议类型
					DeviceModel: '无', // 选中的设备名称  用处：点击单元格，使用测量工具测量，若与之不一致，则无法测量
					ShowDeviceType: false, // 是否显示左下角设备连接状态
				},
				TheMaxRow: 0, // 数据最大行数的索引
				FromDevice: false, // 是否是从设备读取的数据
				isJYResult: '', // 选中的检验结果
				showResult: false, // 点击检验结果列，打开弹层
				originData: { // 单机列表行获取的信息
					mainData: {}, // 主表信息
					inspections: [], // 处理过后的子表信息
				},
				RowInfo: { // luckysheet 行详情弹层
					ShowRowInfo: false, // 是否展示行详情，由点击有信息的行操控
					AllowToShow: false, // 是否允许点击行，显示详情弹层
				},
				ToUnfold: false, // 测试，记录是否展开实测值
				TheValueData: [], // 记录选中项的实测值数据

				HeadLeftData: [], // 实测值左侧的表头数据
				MeasuredMaxLength: 0, // 实测值最大长度

				AddInspectionNum: false, // 点击导航栏新增检验次数弹层
				InspectionNum: '', // 检验次数输入框
				ApproveID: null, // 审核、反审核按钮Type，1：审核，-1 反审核
				BtnApprove: [], // 按钮权限数据
			},
			created: function() {
				var that = this;
				let immersed = 0;
				//获取当前手机状态栏高度
				if (window.localStorage.getItem('safeAreaInsetTop')) {
					immersed = window.localStorage.getItem('safeAreaInsetTop');
				} else {
					let ms = (/Html5Plus\/.+\s\(.*(Immersed\/(\d+\.?\d*).*)\)/gi).exec(navigator
						.userAgent);
					if (ms && ms.length >= 3) { // 当前环境为沉浸式状态栏模式
						immersed = parseFloat(ms[2]); // 获取状态栏的高度
					}
					window.localStorage.setItem('safeAreaInsetTop', immersed)

				}
				this.immersed = immersed;

				// 初始化时，取屏幕宽高的最小值，用于表格列表高度
				const MinNums = Math.min(screen.height, screen.width)
				let SetTableNums = 250

				if (MinNums < 500) {
					SetTableNums = 200
				} else {
					SetTableNums = 250
				}
				this.MinNums = SetTableNums;

				// 查看历史是否有记录允许打开详情弹层
				var isAllow = window.localStorage.getItem('AllowToShowRowInfo');
				if (isAllow && isAllow == 'true') {
					this.RowInfo.AllowToShow = true;
				};

				// 赋值表头部分数据
				that.HeadLeftData = LuckysheetData.LuckysheetHeadMork();

				// 赋值左侧选取范围列
				APP.setReactiveValue(that.AllowableScope, 'c', LuckysheetData.LuckysheetHeadMork().length - 1);

				setTimeout(() => {

					$('#app').css({
						'padding-top': immersed + 'px'
					})
				}, 500)
			},
			watch: {
				'AddFormData.BJNum'(val) { // 监听新增弹层表单中的 来料数量是否有值
					var that = this

					that.Rule.BJNum = !val ? true : false
				},
				'AddFormData.Fbatch'(val) { // 监听新增弹层表单中的批次是否有值
					var that = this

					that.Rule.Fbatch = !val ? true : false
				},
				'AddFormData.ProcedureName'(val) { // 监听新增弹层表单中的工序是否有值
					var that = this

					that.Rule.ProcedureName = !val ? true : false
				},
				'AddFormData.ProductName': { // 监听新增弹层表单中的品号是否存在
					handler(val) {
						var that = this
						that.Rule.ProductName = !val ? true : false
						that.FormPlaceHolder = !val ? false : true
					},
				},
				'AddFormData.JYLX': { // 监听检验类型变化
					handler(val) {
						var that = this
						that.Rule.JYLX = !val ? true : false
					},
				},
				ShowAddInspection: {
					handler(val) {
						var that = this;
						if (!val) return;
						setTimeout(() => {
							console.log($('.AddTabPopup').outerHeight());

							$('.AddTabPopup .el-tabs__content').css({
								'height': ($('.AddTabPopup').height() - $('.el-tabs__header')
									.height() - 10) + 'px'
							})

							//  - $('.Remarks').height()
							$('.ListBoxBottom').css({
								'height': ($('.AddTabPopup').height() - $('.el-tabs__header')
									.height() - 10 - $('.el-table').height()) + 'px',
								// 'line-height': ($('.AddTabPopup').height() - $('.el-tabs__header')
								// 	.height() - 10 - $('.el-table').height()) + 'px',
							})

						}, 50)
					},
				}
			},
			mounted() {
				var that = this;
				that.$nextTick(() => {
					// 点击屏幕任何地方，都触发
					$(document).on('click', function(e) {
						console.log(that.ShowAddInspection);
						if (!that.showEditWindow && !that.ShowAddInspection && !vm.showListBox) {
							const input = document.getElementById('autoInput');
							input.focus(); // 初始聚焦

							input.addEventListener('blur', () => {
								setTimeout(() => input.focus(), 0); // 失焦后立即重新聚焦
							});

						}
					});
				});

				// 在组件挂载后初始化Luckysheet
				setTimeout(() => {
					$('#luckysheet').css({
						'height': `calc( 100vh - ${that.immersed}px - ${$('.van-nav-bar').height()}px - ${$('.bottom').height()}px - 4px ) `
					});
				}, 300);
			},
			beforeDestroy() {},
			methods: {
				// webview 初始化
				page_initConfig(configInfo) {
					let that = this;

					const {
						GetDocumentInfo,
						GetUserInfo,
						SetServiceIP,
						GetBtnPermission,
					} = JSON.parse(configInfo);;

					console.log(GetUserInfo);



					// 存储用户信息
					this.UserInfo = GetUserInfo;
					APP.getUserInfo(GetUserInfo);

					// 存储 IP 信息
					APP.serverIP(SetServiceIP.serverIP);
					APP.IPAgreement(SetServiceIP.IPAgreement);

					setTimeout(() => {
						that.getListFun(0)
						that.getListFun(1)

					}, 300)


					this.BtnApprove = GetBtnPermission


					// 快速打开单据
					// if (GetDocumentInfo) {
					// 	this.GetDocumentInfo(GetDocumentInfo)
					// }


				},



				// 父页面调用子页面方法
				setRange(data) { // 父组件调用子组件事件 - data => 父组件传入的值;
					console.log(data);
					let dataArray = data.split(',');

					this.FromDevice = true;

					//考虑到data是由逗号分割的字符串
					if (dataArray.length > 1) {


					} else {
						const NewData = [
							[{
								"m": data, // 显示值
								"v": data, // 原始值
								"ht": 0, // 水平对齐 0 居中、1 左、2右	
								"vt": 0, // 垂直对齐 0 中间、1 上、2下
								"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行
							}]
						]
						// 首先判断选中单元格是否需要所属检验工具测量
						// IsWhere => A1 => [0,0]
						// 1、获取选中单元格行列位置
						const Iswhere = vm.cellToIndex(vm.IsWhere)
						let r = Iswhere[0]
						let c = Iswhere[1]
						let AllFilterData = [];

						$('#autoInput').val(data)

						vm.submitKeyword(data)

						// 3、如果选中项属于填写数据，且填写设备 Benchmark 为连接设备，则进行赋值操作，并选择下一个，反之，提示错误
						// if (AllFilterData.length) {
						// 	vm.ChoiceCell(NewData)
						// } else {
						// 	vant.Toast('请检查测量设备是否一致，或是否选中正确单元格')
						// }
					}
				},

				getListFun(data) { // 获取检验列表数据
					var that = this
					/* 
					 * data  		接收是否检验： 0 - 未检验、1 - 已检验
					 * pageIndex	需要注意，从 1 开始
					 */
					// 声明两个变量，接收 分页的 属性名称
					let AttributePageName = ""
					if (data == 1) {
						AttributePageName = 'IsPage'
						vm.IsTableLoading = true
					} else {
						AttributePageName = 'NotPage'
						vm.NotTableLoading = true
					};
					let obj = {
						pageIndex: vm[AttributePageName].pageIndex,
						pageSize: vm[AttributePageName].pageSize,
						SFJY: data,
					};

					APP.jqueryAjax('APP_CGJLIST', obj, function(res) {
						let AttributeListName = ''
						let TotalName = ''
						if (data == 1) {
							AttributeListName = 'IsListTableData'
							TotalName = 'IsTotal'

						} else {
							AttributeListName = 'NotListTableData'
							TotalName = 'NotTotal'
						}

						// 给表格赋值
						vm[AttributeListName] = res.data.ds;

						// console.log(JSON.stringify(res.data.ds))

						// 给对应的分页总数 赋值
						vm[TotalName] = (res.data.ds1.length && res.data.ds1[0].Total) ? res.data
							.ds1[0]
							.Total : 0;

						vm[AttributePageName].pageDocumentPage = vm[AttributePageName].pageIndex

						setTimeout(() => {
							if (data == 1) {
								vm.IsTableLoading = false

							} else {
								vm.NotTableLoading = false
							}


							that.$nextTick(() => {
								that.$refs.TableList.doLayout();
							});
						}, 500)
					})


				},
				ChoiceTableCell(row, column, cell, event) { // 单机表格行
					if (column && column.label == '操作') {
						return
					}
					// 记录点击列表项的信息，(主表信息)
					vm.originData.mainData = row;
					// console.log(JSON.stringify(vm.originData.mainData.Approve))
					// console.log(JSON.stringify(row.RoutineInspectionID))

					try {
						APP.jqueryAjax('APP_CGJMX', {
							RoutineInspectionID: row.RoutineInspectionID
						}, function(res) {
							console.log(JSON.stringify(res));

							let FData = JSON.parse(JSON.stringify(res.data.ds))
							let CData = JSON.parse(JSON.stringify(res.data.ds1))
							FData.map(item => {
								item.checked = false;
								item.children = [];
								item.FQCItems = [];
							})

							let map = new Map(FData.map(item => [item.RoutineInspectionDeID, item]));

							CData.forEach(item => {
								item.checked = false;
								let parent = map.get(item
									.RoutineInspectionDeID); // 根据 pid 获取 arr1 数组中对应的对象
								if (parent) {
									parent.children.push(item); // 将当前 item 添加到 parent 的 children 数组中
								}
							});

							// console.log(JSON.stringify(map))

							FData.forEach((item, index) => {
								let result = item.children.reduce((prev, cur) => {

									// 查找数组 prev 中是否已存在 key 为指定属性的值
									let group = prev.find(ReItem => ReItem.key === cur
										.FQCItemName);

									if (group) {
										group.MeasuredValue.push({
											RoutineInspectionDeDeID: cur
												.RoutineInspectionDeDeID ||
												0,
											value: cur.TestResult,
											r: '',
											c: '',
										})
										// 如果存在，将当前元素加入该分组的 value 中
										// group.value.push(cur.TestResult);
										// 实测值修改的最新时间
										group.InspectionTime.push(cur.InspectionTime);

									} else {
										prev.push({
											checked: false,
											key: cur.FQCItemName,
											JYLX: item.JYLX,
											JYLXID: item.JYLXID,
											CJQty: item.CJQty,
											// RoutineInspectionDeDeID: cur.RoutineInspectionDeDeID || 0,
											RoutineInspectionDeID: cur
												.RoutineInspectionDeID,
											RoutineInspectionID: cur
												.RoutineInspectionID,
											ProductID: cur.ProductID,
											ProductName: cur.ProductName,
											ProcedureID: cur.ProcedureID,
											ProcedureName: cur.ProcedureName,
											FQCItemID: cur.FQCItemID,
											PoorWork: cur.PoorWork,
											PoorNormally: cur.PoorNormally,
											JYBZ: cur.JYBZ,
											YPMC: cur.YPMC,
											FResult: cur.FResult,
											FResultID: cur.FResultID,
											FRemarks: cur.FRemarks,
											TestResult: cur.TestResult,
											key: cur.FQCItemName,
											FQCItemName: cur.FQCItemName,
											// value: [cur.TestResult],
											InspectionTime: [cur.InspectionTime],
											Benchmark: cur.Benchmark,
											MeasuredValue: [{
												RoutineInspectionDeDeID: cur
													.RoutineInspectionDeDeID ||
													0,
												value: cur.TestResult,
												r: '',
												c: '',
											}],
										}); // 如果不存在，创建一个新分组，并将当前元素加入该分组的 value 中
									}

									return prev;
								}, []);

								item.FQCItems.push(...result);

								item.FQCItems.forEach(ReItem => {
									// 这里做了处理,小于2000的年份,直接显示空
									if (+ReItem.InspectionTime[0].slice(0, 4) < 2000) {
										ReItem.NewTime = '';
									} else {
										ReItem.NewTime = APP.GetNewTime(ReItem.InspectionTime)
									}
									ReItem.InspectionTime = []
									ReItem.InspectionTime[0] = ReItem.NewTime;

								})
								item.MeasuredValueLength = item.FQCItems[0].MeasuredValue.length;

							})
							console.log(JSON.stringify(FData));

							// 给表格赋值用
							vm.SheetListData = FData;

							vm.ConfigureFormat()

							vm.showListBox = false;
						})

					} catch (e) {
						//TODO handle the exception
						vant.Toast('接口请求错误,请刷新后重试');
					}
				},
				TableViewBtn(data) { // 表格查看 
					// 查看 - 显示列表
					vm.AddEditActive = '0';

					// 需要进入编辑状态，根据 RoutineInspectionID 获取子表列表数据
					vm.GetSonListData(data.RoutineInspectionID);

					vm.RoutineInspectionID = data.RoutineInspectionID;

					// 打开子表列表弹层
					vm.ShowAddInspection = true;

				},
				GetSonListData(ID) { // 获取子表列表数据
					APP.jqueryAjax('selectCGJZLB', {
						RoutineInspectionID: ID
					}, function(res) {
						if (res.status == 200) {
							vm.AddListTableData = res.data.ds;
						}
					})
				},
				OpenAddInspection() { // 打开新增检验次数弹层
					vm.AddInspectionNum = true;
					vm.InspectionNum = '';
				},
				CloseAddCloumnPopup() { //  关闭新增检验次数弹层
					vm.AddInspectionNum = false;
					vm.InspectionNum = '';
				},
				AddInspection() { // 新增子表数据，新增检验次数
					if (APP.isEmpty(vm.InspectionNum)) {
						return vant.Toast('请输入检验次数')
					}

					let TheWhere = vm.IsWhere;

					let MeasuredMaxLength = vm.MeasuredMaxLength;
					let count = vm.InspectionNum;
					let sum = +vm.AllowableScope["c"] + +vm.MeasuredMaxLength + 1;
					// 在指定位置插入列
					luckysheet.insertColumn(sum, {
						number: count
					})
					// 增加实测值选区范围
					vm.MeasuredMaxLength = +vm.MeasuredMaxLength + +count;

					// 差一步操作，给原有数组，增加对应的检验次数、修改变量中的实测值范围等数据

					vm.SheetListData.forEach((item, index) => {
						// 给每一项子表增加抽检次数的值
						item.CJQty = +item.CJQty + +count;

						item.FQCItems.forEach(ReItem => {
							ReItem.CJQty = +ReItem.CJQty + +count;

							for (let i = 0; i < count; i++) {
								let obj = {
									"RoutineInspectionDeDeID": 0,
									"value": "",
									"r": ReItem.MeasuredValue[0]["r"],
									"c": ReItem.MeasuredValue[ReItem.MeasuredValue.length - 1][
										"c"
									] + 1
								};
								ReItem.MeasuredValue.push(obj)
							}

							// ReItem.ChildData 要修改

						})
					})
					for (let i = 0; i < count; i++) {
						// 给头部增加位置数字，赋值
						const NewData = [
							[{
								"m": MeasuredMaxLength + i + 1, // 显示值
								"v": MeasuredMaxLength + i + 1, // 原始值
								"ht": 0, // 水平对齐 0 居中、1 左、2右	
								"vt": 0, // 垂直对齐 0 中间、1 上、2下
								"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行
							}]
						];

						let IsWhere = vm.indexToCell([0, +vm.AllowableScope["c"] + +MeasuredMaxLength + i + 1]);

						//回写单元格
						luckysheet.setRangeValue(NewData, {
							range: IsWhere + ':' + IsWhere
						});

						// if (APP.isEmpty(TheWhere)) {
						// 	TheWhere = 'A1'
						// }

						// // 选中
						// luckysheet.setRangeShow(TheWhere + ':' + TheWhere);

						vm.CloseAddCloumnPopup();
					}
				},
				OpenInspectionData() { // 打开去添加检验产品
					vm.IsOpenInspectionData = true; // 初始化后，添加产品
					vm.AddEditActive = '1'; // 将页签转到新增
					vm.showListBox = true; // 打开列表弹层
					vm.ShowAddInspection = true; // 打开新增弹层
				},
				CloseAddDataPopup() { // 关闭直接打开的新增弹层
					vm.showListBox = false; // 关闭列表弹层
					setTimeout(() => {
						vm.AddEditActive = '0';
						vm.IsOpenInspectionData = false; // 初始化后，添加产品
						// 清除所有的表单选项
						vm.RoutineInspectionID = ''; // 单据ID手动清空
						vm.AddAllowBack = true; // 允许关闭
						vm.ShowAddInspection = false; // 关闭弹层
						vm.AddListTableData = []; // 列表置空
						Object.keys(vm.AddFormData).forEach(key => {
							if (vm.AddFormData[key] instanceof Array) {
								vm.AddFormData[key] = []
							} else if (typeof vm.AddFormData[key] == Object) {
								vm.AddFormData[key] = {};
							} else {
								vm.AddFormData[key] = '';
							}
						})

						setTimeout(() => {
							Object.keys(vm.Rule).forEach(key => {
								vm.Rule[key] = false;
							})
						}, 5)
					}, 300)
				},
				ToScan() { // 扫码
					uni.postMessage({
						data: {
							action: 'ToScan'
						}
					});
				},
				GetToScanInfo(data) { // 获取扫码结果
					var NewData = data.result;
					var TheIndex = NewData.indexOf('|');
					if (TheIndex != -1) {
						NewData = NewData.slice(TheIndex + 1)
					}

					var obj = {
						QrCode: NewData
					}
					APP.jqueryAjax('selectCPXXByERWM', obj, function(res) {
						if (res.status == 200) {
							vm.AddFormData = Object.assign(vm.AddFormData, res.data.ds[0]);

							vm.GetCJQty()
						}
					}, function(err) {
						console.log(JSON.stringify(err))
					})
				},
				DeleteAddRow(data) { // 删除行
					// 获取在数组中的索引
					let TheIndex = vm.AddListTableData.indexOf(data)
					vm.AddListTableData.splice(TheIndex, 1); // 删除行数据
				},
				AddSubmit() { // 确认新增
					var that = this;
					if (vm.AddListTableData.length) {

						let FilterData = [];
						let cmd = 'selectCGJByCPGX'; // 新增
						let obj = {
							CJQty: [], // 抽检数量
							Fbatch: [], // 批次
							Qty: [], // 检验数量
							ProcedureID: [], // 工序id
							ProductName: [], // 品名
							ProductID: [], // 产品id
							ProductSpec: [], // 规格
							// FMaterials: [], // 材质
							JYLX: [], // 检验类型
							SFJY: [], // 是否检验
							FResult: [], // 检验结果
							ReceiveNum: [], // 接收数量
							RejectionNum: [], // 拒收数量
							AQL: [], // 抽样方案
						}

						// 没有主键ID的新增
						if (!vm.RoutineInspectionID) {
							FilterData = vm.AddListTableData;
						} else {
							FilterData = vm.AddListTableData.filter(item => {
								return item.RoutineInspectionDeID == 0;
							})
							cmd = 'UpdateCGJCJSL';
							obj['RoutineInspectionID'] = vm.RoutineInspectionID;
						};

						FilterData.forEach(item => {
							obj.Qty.push(item.BJNum);
							obj.CJQty.push(item.CJQty);
							obj.Fbatch.push(item.Fbatch);
							obj.ProcedureID.push(item.ProcedureID);
							obj.ProductName.push(item.ProductName);
							obj.ProductID.push(item.ProductID);
							obj.ProductSpec.push(item.ProductSpec);
							// obj.FMaterials.push(item.FMaterials);
							obj.JYLX.push(item.JYLXID);
							obj.SFJY.push(item.SFJY ? item.SFJY : 0);
							obj.FResult.push(-1);
							// obj.FResult.push(item.FResult ? item.FResult : 1);
							obj.ReceiveNum.push(item.ReceiveNum);
							obj.RejectionNum.push(item.RejectionNum);
							obj.AQL.push(item.AQL);
						});

						Object.keys(obj).forEach(key => {
							if (key != 'RoutineInspectionID') {
								obj[key] = obj[key].join('~')
							}
						})
						APP.jqueryAjax(cmd, obj, function(res) {

							if (res.status == 200) {
								vm.RefreshTables();
								vm.AddListTableData = []; // 列表置空
								vm.AddAllowBack = true; // 允许关闭
								vm.CloseAddPopup(); // 关闭弹层

								vant.Toast('编辑成功');


								that.$nextTick(() => {
									that.$refs.TableList.doLayout();
								})
							}
						});

					} else {
						vant.Toast('列表暂无数据，请前往新增');
					}
				},
				AppPushList() { // 新增列表数据

					if (APP.isEmpty(vm.AddFormData.JYLX) || APP.isEmpty(vm.AddFormData.ProcedureID) || APP.isEmpty(vm
							.AddFormData.ProductID) || APP.isEmpty(vm.AddFormData.Fbatch) || APP.isEmpty(vm
							.AddFormData.BJNum)) {

						if (APP.isEmpty(vm.AddFormData.JYLX)) { // 如果 检验类型 没有值
							vm.Rule.JYLX = true;
						};

						if (APP.isEmpty(vm.AddFormData.ProductID)) { // 如果 品号 和 工序 没有值
							vm.Rule.ProductName = true;
							vm.Rule.ProcedureName = true;
						};

						if (APP.isEmpty(vm.AddFormData.ProcedureID)) { // 如果 品号 和 工序 没有值
							vm.Rule.ProcedureName = true;
						};

						if (APP.isEmpty(vm.AddFormData.BJNum)) { // 如果抽检数量没有值
							vm.Rule.BJNum = true;
						};
						if (APP.isEmpty(vm.AddFormData.Fbatch)) { // 如果批次没有值
							vm.Rule.Fbatch = true;
						};

						return vant.Toast('请完善表单信息');
					};

					const currentTime = Date.now(); // 获取当前时间
					const timeDiff = currentTime - this.lastClickTime; // 计算与上一次执行时间的差

					if (timeDiff >= this.throttleTime) {
						layer.open({
							content: '+1',
							skin: 'msg',
							time: 2
						});
						let newFormData = APP.deepClone(vm.AddFormData);

						// 如果是新增到列表
						if (!vm.IsOpenInspectionData) {
							newFormData['RoutineInspectionID'] = vm.AddListTableData.length ? vm.AddListTableData[0][
								'RoutineInspectionID'
							] : 0;
							newFormData['RoutineInspectionDeID'] = 0;
							newFormData.ProcedureID = +newFormData.ProcedureID;
							newFormData.BJNum = +newFormData.BJNum;
							newFormData.CJQty = +newFormData.CJQty;
							newFormData.ReceiveNum = +newFormData.ReceiveNum;
							newFormData.RejectionNum = +newFormData.RejectionNum;
							// push 到列表
							vm.AddListTableData.push(newFormData);


						} else {
							// 先保存原有数据，再直接调新增
							let WaitSubmitData = JSON.parse(JSON.stringify(vm.SheetListData));
							let data = vm.DisposeSubData(WaitSubmitData);
							let originData = {
								mainData: vm.originData.mainData,
								inspections: data.WaitSubmitData,
								FQCDetail: data.ValueData
							}

							let newFormDataa = JSON.parse(JSON.stringify(vm.AddFormData));
							APP.jqueryAjax('updateRoutine', {
								json: JSON.stringify(originData)
							}, function(res) {
								let FilterData = [];

								// let newFormData = APP.deepClone(vm.AddFormData);
								let newFormData = JSON.parse(JSON.stringify(newFormDataa));
								newFormData.ProcedureID = +newFormData.ProcedureID;
								newFormData.BJNum = +newFormData.BJNum;
								newFormData.CJQty = +newFormData.CJQty;
								newFormData.ReceiveNum = +newFormData.ReceiveNum;
								newFormData.RejectionNum = +newFormData.RejectionNum;

								FilterData.push(newFormData)

								// 把子表数据存一下，获取这条数据的主键ID，再去给子子表id赋值
								let obj = {
									CJQty: [], // 抽检数量
									Fbatch: [], // 批次
									Qty: [], // 检验数量
									ProcedureID: [], // 工序id
									ProductName: [], // 品名
									ProductID: [], // 产品id
									ProductSpec: [], // 规格
									// FMaterials: [], // 材质
									JYLX: [], // 检验类型
									SFJY: [], // 是否检验
									FResult: [], // 检验结果
									ReceiveNum: [], // 接收数量
									RejectionNum: [], // 拒收数量
									AQL: [], // 抽样方案
									RoutineInspectionID: originData.mainData
										.RoutineInspectionID, // 子表主键ID
								}

								FilterData.forEach(item => {
									obj.Qty.push(item.BJNum);
									obj.CJQty.push(item.CJQty);
									obj.Fbatch.push(item.Fbatch);
									obj.ProcedureID.push(item.ProcedureID);
									obj.ProductName.push(item.ProductName);
									obj.ProductID.push(item.ProductID);
									obj.ProductSpec.push(item.ProductSpec);
									// obj.FMaterials.push(item.FMaterials);
									obj.JYLX.push(item.JYLXID);
									obj.SFJY.push(item.SFJY ? item.SFJY : 0);
									obj.FResult.push(-1);
									// obj.FResult.push(item.FResult ? item.FResult : 1);
									obj.ReceiveNum.push(item.ReceiveNum);
									obj.RejectionNum.push(item.RejectionNum);
									obj.AQL.push(item.AQL);
								});

								// setTimeout(() => {
								Object.keys(obj).forEach(key => {
									if (key !== 'RoutineInspectionID') {
										let KeyData = obj[key];
										if (Array.isArray(KeyData)) {
											obj[key] = KeyData.join('~');
										}
									}
								});
								// }, 500);

								// return

								APP.jqueryAjax('UpdateCGJCJSL', obj, function(res) {
									if (res.status == 200) {
										// 这里会拿到新添加的子表数据下的子子表数据。
										// let RowData = {
										// 	RoutineInspectionID: vm.originData.mainData
										// 		.RoutineInspectionID
										// }
										vm.ChoiceTableCell(vm.originData.mainData);
										vm.ShowAddInspection = false;
										vm.IsOpenInspectionData = false;
									}
								});
							}, function(err) {

							}, 1)


						}

						// 修改新增弹层回退状态，避免点击误触
						vm.AddAllowBack = false;

						setTimeout(() => {
							Object.keys(vm.AddFormData).forEach(key => {
								if (vm.AddFormData[key] instanceof Array) {
									vm.AddFormData[key] = []
								} else if (typeof vm.AddFormData[key] == Object) {
									vm.AddFormData[key] = {};
								} else {
									vm.AddFormData[key] = '';
								}
							})

							setTimeout(() => {
								Object.keys(vm.Rule).forEach(key => {
									vm.Rule[key] = false;
								})
							}, 5)
						}, 500)
						this.lastClickTime = currentTime; // 更新上一次执行时间
					}


				},
				hasSame(obj, arr) {
					let hasSame = arr.some(item => {
						return item.ProductID == obj.ProductID && item.JYLXID === obj.JYLXID && item
							.ProcedureID == obj.ProcedureID
					})
					return hasSame
				},
				AddInspectionBtn() { // 打开列表新增弹层
					// Tab切换到新增
					vm.AddEditActive = '1';
					vm.ShowAddInspection = true;
				},
				CloseAddPopup() { // 关闭列表新增弹层
					if (!vm.AddAllowBack) {
						vant.Dialog.confirm({
							title: '提示',
							message: '列表数据有变化，是否确认离开？',
						}).then(() => {
							vm.RoutineInspectionID = ''; // 单据ID手动清空
							vm.AddAllowBack = true; // 允许关闭
							vm.ShowAddInspection = false; // 关闭弹层
							vm.AddListTableData = []; // 列表置空
							Object.keys(vm.AddFormData).forEach(key => {
								if (vm.AddFormData[key] instanceof Array) {
									vm.AddFormData[key] = []
								} else if (typeof vm.AddFormData[key] == Object) {
									vm.AddFormData[key] = {};
								} else {
									vm.AddFormData[key] = '';
								}
							})

							setTimeout(() => {
								Object.keys(vm.Rule).forEach(key => {
									vm.Rule[key] = false;
								})
							}, 5)
						}).catch(() => {
							// on cancel
							// return
						});
					} else {
						vm.RoutineInspectionID = ''; // 单据ID手动清空
						vm.AddAllowBack = true; // 允许关闭
						vm.ShowAddInspection = false; // 关闭弹层
						vm.AddListTableData = []; // 列表置空
						Object.keys(vm.AddFormData).forEach(key => {
							if (vm.AddFormData[key] instanceof Array) {
								vm.AddFormData[key] = []
							} else if (typeof vm.AddFormData[key] == Object) {
								vm.AddFormData[key] = {};
							} else {
								vm.AddFormData[key] = '';
							}
						})

						setTimeout(() => {
							Object.keys(vm.Rule).forEach(key => {
								vm.Rule[key] = false;
							})
						}, 5)
					}


				},
				GetBaseCreenBack(val) { // 接收下拉筛选返回的值
					let that = this;
					// 判断是否为空对象
					if (!APP.isEmpty(val)) {
						let data = JSON.parse(val);

						if (data.titleName == '品号') {
							APP.jqueryAjax('APP_GetCPXXByCPID', {
								ProductID: data.data.ProductID
							}, function(res) {
								if (res.status == 200) {
									let excludeArr = ["JYLX", "JYLXID"];

									APP.clearFormData(vm.AddFormData, excludeArr)

									vm.AddFormData = Object.assign(vm.AddFormData, res.data.ds[0]);
								}
							})
						} else if (data.titleName == '工序') {
							that.AddFormData = Object.assign(that.AddFormData, data.data);

						} else if (data.titleName == '检验类型') {
							let obj = {
								JYLX: data.data.name,
								JYLXID: data.data.id
							}
							let excludeArr = [];

							APP.clearFormData(vm.AddFormData, excludeArr)
							that.AddFormData = Object.assign(that.AddFormData, obj);

						}
					}
				},
				openBaseScreen(data) { // 前往筛选，将参数带上
					let that = this;
					if (data != '检验类型' && APP.isEmpty(vm.AddFormData.JYLXID)) {
						return vant.Toast.fail('请选择检验类型')
					}

					if (data == '工序' && !vm.AddFormData.ProductName) {
						return vant.Toast.fail('请选择品号')
					}

					vm.SelectName = data;

					let obj = null;
					let path = '';

					if (data == '工序') {
						path = 'selectGXXXByCPID';

						obj = {
							allowClear: false, // 清除按钮
							cmd: path, // 接口名
							titleName: data,
							multiple: false, // 是否开启多选
							serverSearch: { // 查询项
								format: { // 数据映射
									displayValue: "ProcedureName", // 显示值
									hiddenValue: "ProcedureID", // 隐藏值
								},
								isPaging: false, //是否分页
								choiceData: vm.AddFormData.ProcedureID, // 选中数据
								choiceDataKey: "ProcedureID", // 选中数据的key
							},
							param: { // 传递参数
								ProductID: vm.AddFormData.ProductID,
								InspectionID: vm.AddFormData.JYLXID,
							}
						}
					} else if (data == '品号') {
						path = 'Droplist_CPProduct';

						obj = {
							allowClear: false, // 清除按钮
							cmd: path, // 接口名
							titleName: data,
							multiple: false, // 是否开启多选
							serverSearch: { // 查询项
								format: { // 数据映射
									displayValue: "ProductName", // 显示值
									hiddenValue: "ProductID", // 隐藏值
									pageIndex: "pageIndex", // 分页状态页码字段
									pageSize: "pageSize", // 分页状态每页数量字段
								},
								isPaging: true, //是否分页
								searchKey: 'ProductName', //搜索关键词，应包含在param中
								choiceData: vm.AddFormData.ProductID, // 选中数据
								choiceDataKey: "ProductID", // 选中数据的key
							},
							param: { // 传递参数
								ProductName: '',
								InspectionID: this.AddFormData.JYLXID,
								pageIndex: 1,
								pageSize: 30,
							}
						}

					} else if (data == '检验类型') {
						path = 'selectSJANDXJ';

						obj = {
							allowClear: false, // 清除按钮
							cmd: path, // 接口名
							titleName: data,
							multiple: false, // 是否开启多选
							serverSearch: { // 查询项
								format: { // 数据映射
									displayValue: "name", // 显示值
									hiddenValue: "id", // 隐藏值
								},
								isPaging: false, //是否分页
								choiceData: vm.AddFormData.JYLXID, // 选中数据
								choiceDataKey: "id", // 选中数据的key
							},
							param: { // 传递参数
							}
						}
					}



					that.SendMessage('baseScreen', obj)
				},
				// 向外部通讯
				SendMessage(Text, data) { // 向外部发送

					let Obj = {
						action: Text,
						param: {
							url: '',
							title: '',
						},
					}

					if (Text == 'baseScreen') { // 筛选下拉
						Obj['param'] = data
					}
					console.log(JSON.stringify(Obj))

					uni.postMessage({
						data: Obj
					});
				},
				// openBaseScreen(data) { // 筛选弹层

				// 	if (data != '检验类型' && APP.isEmpty(vm.AddFormData.JYLXID)) {
				// 		return vant.Toast.fail('请选择检验类型')
				// 	}

				// 	if (data == '工序' && !vm.AddFormData.ProductName) {
				// 		return vant.Toast.fail('请选择品号')
				// 	}

				// 	vm.SelectName = data
				// 	vm.showBaseScreen = true
				// 	setTimeout(() => {
				// 		$('.head-index').css({
				// 			'padding-top': vm.immersed + 'px'
				// 		})
				// 	}, 300)
				// 	let url = {}
				// 	let obj = {}

				// 	if (data == '工序') {
				// 		url = 'selectGXXXByCPID'
				// 		obj = {
				// 			ProductID: vm.AddFormData.ProductID,
				// 			InspectionID: vm.AddFormData.JYLXID,
				// 		}
				// 	} else if (data == '品号') {
				// 		url = 'Droplist_CPProduct'
				// 		obj = {
				// 			InspectionID: vm.AddFormData.JYLXID
				// 		}
				// 	} else if (data == '检验类型') {
				// 		url = 'selectSJANDXJ'
				// 		obj = {}
				// 	}

				// 	vm.GetInterfaceData(url, obj, data)
				// },
				// GetInterfaceData(cmd, pram, name) { // 获取筛选列表数据
				// 	APP.jqueryAjax(cmd, pram, function(res) {
				// 		if (res.status == 200) {
				// 			res.data.ds.forEach(item => {
				// 				if (name == '工序') {
				// 					item.name = item['ProcedureName']
				// 					// item.name = item['ProcedureCode'] + '|' + item['ProcedureName']
				// 				} else if (name == '品号') {
				// 					item.name = item['ProductName']
				// 				}
				// 			})
				// 			vm.FilterList = res.data.ds
				// 		}
				// 	})
				// },
				CloseBaseScreen() {
					vm.showBaseScreen = false;
					vm.FilterList = [];
				},
				ChoiceListCell(data) { // 选中筛选项
					if (vm.SelectName == '品号') {
						APP.jqueryAjax('APP_GetCPXXByCPID', {
							ProductID: data.ProductID
						}, function(res) {
							if (res.status == 200) {

								vm.AddFormData = Object.assign(vm.AddFormData, res.data.ds[0]);
							}
						})
					} else if (vm.SelectName == '检验类型') {
						// 置空
						Object.keys(vm.AddFormData).forEach(key => {
							if (vm.AddFormData[key] instanceof Array) {
								vm.AddFormData[key] = []
							} else if (typeof vm.AddFormData[key] == Object) {
								vm.AddFormData[key] = {};
							} else {
								vm.AddFormData[key] = '';
							}
						})

						// setTimeout(() => {
						Object.keys(vm.Rule).forEach(key => {
							vm.Rule[key] = false;
						})
						vm.AddFormData.JYLXID = data.id;
						vm.AddFormData.JYLX = data.name;
						// }, 5)
					} else {
						// console.log(JSON.stringify(data))

						vm.AddFormData = Object.assign(vm.AddFormData, data);
						// console.log(JSON.stringify(vm.AddFormData))
					}
					vm.CloseBaseScreen()
				},
				isAllZero(str) { // 判断字符串是否都是 0，或者 ''
					return /^0*$/.test(String(str).trim());
				},
				GetCJQty() { // 来料失焦时，根据来料数量获取抽检数量
					if (APP.isEmpty(vm.AddFormData.BJNum) || vm.isAllZero(vm.AddFormData.BJNum)) {
						vm.AddFormData.ReceiveNum = '';
						vm.AddFormData.RejectionNum = '';
						vm.AddFormData.CJQty = '';
						vm.AddFormData.AQL = '';
						return
					}

					if (vm.AddFormData.BJNum) {
						let pram = {
							ProductID: vm.AddFormData.ProductID,
							BJNum: vm.AddFormData.BJNum,
						}

						APP.jqueryAjax('APP_selectCJSL', pram, function(res) {
							if (res.data.ds.length && res.data.ds[0].status == 200) {
								vm.AddFormData.CJQty = res.data.ds[0]['SizeNum'];
								vm.AddFormData.AQL = res.data.ds[0]['AQL'];
								vm.AddFormData.ReceiveNum = res.data.ds[0]['ReceiveNum'];
								vm.AddFormData.RejectionNum = res.data.ds[0]['RejectionNum'];
							} else if (res.data.ds.length && res.data.ds[0].status == 500) {
								vant.Toast(res.data.ds[0].msg)
								vm.AddFormData.BJNum = ''
								vm.AddFormData.CJQty = ''
								vm.AddFormData.AQL = ''
								vm.AddFormData.ReceiveNum = ''
								vm.AddFormData.RejectionNum = ''
							} else {
								vant.Toast('接口异常，请重试')
							}
						})
					} else {
						vm.AddFormData.CJQty = ''
						vm.AddFormData.AQL = ''
						vm.AddFormData.ReceiveNum = ''
						vm.AddFormData.RejectionNum = ''
					}
				},
				OpenControl() { // 切换设备

					this.SendMessage('openDeviceControl')

				},
				OpenListPopup() { // 选中打开单据列表
					vm.showListBox = true
					// 获取Tabs下 表格数据
					vm.getListFun(0)
					vm.getListFun(1)
					// vm.getListFun(2)

				},
				OpenRowInfo() { // 点击允许开启行详情
					vm.RowInfo.AllowToShow = !vm.RowInfo.AllowToShow;
					window.localStorage.setItem('AllowToShowRowInfo', vm.RowInfo.AllowToShow)
				},
				CloseRowInfo() { // 关闭行详情
					vm.RowInfo.ShowRowInfo = false;
					vm.TheValueData = [];

					vm.ToggleUnfold()
				},
				ToggleUnfold() { // 行详情展开弹层的实测值
					let TheValueData = [],
						CJQty = 0,
						widths = 40;
					vm.TheValueData = [];
					if (!vm.ToUnfold) {
						widths = 80;

						TheValueData = JSON.parse(JSON.stringify(vm.ChoiceRowInfo.MeasuredValue));

						CJQty = vm.Choice_In_ListInfo.RowActualCJQty;

						TheValueData = TheValueData.slice(0, CJQty)

						vm.TheValueData = TheValueData;
					}
					setTimeout(() => {
						$('.RowInfoBox').css({
							'width': widths + 'vw'
						})
						vm.ToUnfold = !vm.ToUnfold;
					}, 300)
				},
				ChoiceWhere(data, index) { // 点击行详情展开弹层的实测值，将 luckysheet 的单元格聚焦
					let TheRange = [data.r, data.c];
					let IsWhere = vm.indexToCell(TheRange);

					vm.IsWhere = IsWhere;

					luckysheet.setRangeShow(IsWhere + ':' + IsWhere);

				},
				ChangePageIndex(data) { // 修改检验表格 页码
					var that = this;
					clearTimeout(that.PageIndexTimer)

					that.PageIndexTimer = setTimeout(() => {
						vm.getListFun(data)
					}, 400)
				},
				DisposeSubData(data) { // 处理需要提交的数据格式

					let WaitSubmitData = JSON.parse(JSON.stringify(vm.SheetListData));

					let ValueData = []; // 子子表数据

					for (let [index, item] of WaitSubmitData.entries()) {
						// WaitSubmitData.forEach(item => {
						delete item['children'];
						delete item['range'];

						let NewFQCItems = [];

						for (let [ind, ReItem] of item.FQCItems.entries()) {
							delete ReItem['ChildData'];
							let CJQty = 0;
							CJQty = ReItem.CJQty;
							ReItem.MeasuredValue = ReItem.MeasuredValue.slice(0, CJQty);

							ReItem.value = '';

							for (let [SonIndex, ReItems] of ReItem.MeasuredValue.entries()) {
								let obj = {
									RoutineInspectionID: ReItem.RoutineInspectionID,
									RoutineInspectionDeID: ReItem.RoutineInspectionDeID,
									RoutineInspectionDeDeID: ReItems.RoutineInspectionDeDeID || 0,
									YPMC: ReItem.YPMC,
									FQCItemName: ReItem.FQCItemName,
									FQCItemID: ReItem.FQCItemID,
									JYBZ: ReItem.JYBZ,
									FResult: ReItem.FResult,
									FResultID: ReItem.FResultID,
									Benchmark: ReItem.Benchmark,
									value: ReItems.value,
									FRemarks: ReItem.FRemarks,
									InspectionTime: ReItem.NewTime,
								}
								NewFQCItems.push(obj)
							}
							delete ReItem['MeasuredValue'];
						}

						delete item['FQCItems'];
						item.NewFQCItems = NewFQCItems;
						ValueData.push(...NewFQCItems)
						delete item['NewFQCItems'];
					}

					let Obj = {
						ValueData: ValueData,
						WaitSubmitData: WaitSubmitData,
					}
					return Obj
				},
				ApproveBtn() { // 审核、反审核按钮
					let ApproveMsg = '是否提交审核';
					let ApproveID = 1;

					if (vm.originData.mainData.Approve != '未审核') {
						ApproveMsg = '是否撤销审核';
						ApproveID = -1;
					}

					vm.ApproveID = ApproveID;

					vant.Dialog.confirm({
						title: '提示',
						message: ApproveMsg,
					}).then(() => {
						// on confirm
						vm.SubmitBtn();
					}).catch(() => {
						// on cancel
					})


				},
				SubmitBtn() { // 提交按钮
					vm.showLoading = true;

					// 记录是否有空值
					let hasEmpty = false;

					let WaitSubmitData = JSON.parse(JSON.stringify(vm.SheetListData));
					// 孚沃得，解除限制
					if (vm.UserInfo.Business_Code != '010') {

						// return

						let TheEmptyData = [];
						for (let [index, item] of WaitSubmitData.entries()) {
							// 1、把检验结果是忽略的过滤掉
							let hasEmptyData = item.FQCItems.filter(obj => obj['FResultID'] !== -1);
							TheEmptyData.push(...hasEmptyData)

							for (let [index, ReItem] of hasEmptyData.entries()) {
								ReItem.MeasuredValue = ReItem.MeasuredValue.slice(0, ReItem.CJQty);
								// 2、检查检验项的实测值是否全部填写完毕，没有就提示

								let isEmpty = ReItem.MeasuredValue.some(ret => {
									return APP.isEmpty(ret['value'])
								})

								if (isEmpty) {
									hasEmpty = true;
									break;
								}

							}
						}

						if (hasEmpty) {
							vm.showLoading = false;
							let ranges = {
								r: 0,
								c: 0
							}

							for (let [index, item] of TheEmptyData.entries()) {
								let Data = item['MeasuredValue'].findIndex(ReItem => APP.isEmpty(ReItem.value));
								if (Data != -1) {
									ranges.r = item['MeasuredValue'][Data]['r'];
									ranges.c = item['MeasuredValue'][Data]['c'];
									let IsWhere = vm.indexToCell([ranges.r, ranges.c]);
									vm.IsWhere = IsWhere;
									// 将单元格高亮
									luckysheet.setRangeShow(IsWhere + ':' + IsWhere);

									return vant.Toast('请检查表格内容是否完整');
									break;
								}
							}

						}

						// 过滤掉子表没有数据的
						let filterData = WaitSubmitData.filter(item => {
							return item.FQCItems.length > 0
						})

						// 如果子表没有数据，不允许提交
						if (filterData.length == 0) {
							vm.showLoading = false;
							return vant.Toast('列表至少保留一条数据');
						}
					}

					let data = vm.DisposeSubData(WaitSubmitData);
					// return
					let originData = {
						mainData: vm.originData.mainData,
						inspections: data.WaitSubmitData,
						FQCDetail: data.ValueData
					}
					// vm.showLoading = false;
					// return

					APP.jqueryAjax('updateRoutine', {
						json: JSON.stringify(originData)
					}, function(res) {
						if (res.status == 200) {
							if (!APP.isEmpty(vm.ApproveID)) { // 如果点击了审核、反审核按钮
								APP.jqueryAjax('APP_FWDSHCGJ', {
									RoutineInspectionID: vm.originData.mainData.RoutineInspectionID,
									Type: vm.ApproveID,
									UserID: vm.UserInfo.UserID,
								}, function(res) {
									// console.log(JSON.stringify(res));
									if (res.data.ds[0].status == 200) {
										if (vm.ApproveID == 1) {
											vm.originData.mainData.Approve = '已审核';
										} else {
											vm.originData.mainData.Approve = '未审核';
										}
									}
									vant.Toast.success(res.data.ds[0].msg)
									vm.ApproveID = null;
									vm.showLoading = false;
								})
							} else {
								setTimeout(() => {
									vm.showLoading = false;
									vant.Toast.success('保存成功！')
								}, 1000);
							}
						} else {
							setTimeout(() => {
								vm.showLoading = false;
							}, 1000);
						}
					}, function(err) {
						setTimeout(() => {
							vant.Toast.fail('服务器异常，请重试')
							vm.showLoading = false;
						}, 1000);
					}, 1)


				},
				GetDataInfo() { // 获取 luckysheet 数据

				},
				ConfigureFormat() { // 配置 luckysheet 展示格式
					var that = this;

					// console.log(JSON.stringify(that.SheetListData))
					// 获取实测值最大长度
					var MaxLength = APP.getMaxPropertyValue(that.SheetListData, 'MeasuredValueLength');
					// var MaxLength = that.findMaxMeasuredValueLength(that.SheetListData.FQCItems, 'MeasuredValue');
					// console.log(MaxLength)
					that.MeasuredMaxLength = MaxLength;

					// 头部数据，这里就是固定的
					var allCellData = JSON.parse(JSON.stringify(that.HeadLeftData));

					for (let i = 0; i < MaxLength; i++) {
						let data = {
							"r": 0,
							"c": that.AllowableScope["c"] + i + 1,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": i + 1, //内容的原始值为 233
								"m": i + 1, //内容的显示值为 233
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						};

						allCellData.push(data)
					}

					let LastData = [{
							"r": 0,
							"c": that.AllowableScope["c"] + MaxLength + 1,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": '检验结果', //内容的原始值为 233
								"m": '检验结果', //内容的显示值为 233
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						},
						{
							"r": 0,
							"c": that.AllowableScope["c"] + MaxLength + 2,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": '备注', //内容的原始值为 233
								"m": '备注', //内容的显示值为 233
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						}, {
							"r": 0,
							"c": that.AllowableScope["c"] + MaxLength + 3,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": '检验时间', //内容的原始值为 233
								"m": '检验时间', //内容的显示值为 233
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						}
					]
					allCellData.push(...LastData);


					/* var dataVerfications = {}
					dataVerfications[(headerLevel + 1 + i) + '_' + colNums] = {
						type: 'checkbox',
						type2: null,
						value1: '合格',
						value2: '不合格',
						checked: (that.originData.inspections[i].result == '1' ? true : false)
					} */

					// let data = that.SheetListData;

					// 最左侧复选框
					let dataVerfications = {}

					let GetNewData = []


					let num = 0;
					that.SheetListData.forEach((item, index) => {
						let rangeData = []

						item.FQCItems.forEach((ReItem, ind) => {

							// 这一段应该就是给插入复选框
							dataVerfications[(1 + num) + '_' + 0] = {
								type: 'checkbox',
								type2: null,
								value1: '',
								value2: '',
								checked: ReItem.checked
							}

							dataVerfications[(1 + num) + '_' + (+that.AllowableScope["c"] + +
								MaxLength + 1)] = {
								type: 'checkbox',
								type2: null,
								value1: '',
								value2: '',
								checked: ReItem.FResultID == 1 ? true : false
							}

							let newData = that.callbackObj(ReItem, num);

							ReItem.rowIndex = num + 1;

							ReItem.ChildData = newData;

							rangeData.push(...newData);
							num += 1;
						})

						// 获取产品占有的行范围
						let minRow = Math.min.apply(Math, rangeData.map(function(obj) {
							return obj.r;
						}));
						let maxRow = Math.max.apply(Math, rangeData.map(function(obj) {
							return obj.r;
						}));

						item.range = [minRow, maxRow];
						allCellData.push(...rangeData)

					})

					// 计算数据占有的最大行数的索引
					let TheMaxRow = that.SheetListData.reduce((accumulator, obj) => {
						return accumulator + obj.FQCItems.length;
					}, 0);
					that.TheMaxRow = TheMaxRow;

					this.ExcleInit(5, 20, allCellData, dataVerfications)

				},
				callbackObj(data, index) {
					var that = this;
					const rowIndex = index + 1; // 行
					let NewArr = [];

					// 定义前几项文本项
					for (let i = 0; i <= that.AllowableScope.c; i++) {
						let obj = {
							"r": rowIndex,
							"c": i,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": '', //内容的原始值
								"m": '', //内容的显示值
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, // 单元格文本水平位置  0 居中、1 左、2右
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						};
						if (i == 0) {
							obj.v.v = data.ProductName;
							obj.v.m = data.ProductID;
							obj.v.ht = 1;
						} else if (i == 1) {
							obj.v.v = data.JYLX;
							obj.v.m = data.JYLXID;
						} else if (i == 2) {
							obj.v.v = data.ProcedureName;
							obj.v.m = data.ProcedureName;
						} else if (i == 3) {
							obj.v.v = data.FQCItemName;
							obj.v.m = data.FQCItemName;
						} else if (i == 4) {
							obj.v.v = data.JYBZ;
							obj.v.m = data.JYBZ;
						};

						NewArr.push(obj);
					};

					// 定义实测值
					data.MeasuredValue = data.MeasuredValue.map((item, index) => {
						let obj = {
							"r": rowIndex,
							"c": index + that.AllowableScope.c + 1,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": item.value, //内容的原始值
								"m": item.value, //内容的显示值
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						};
						if (index + 1 > data.CJQty) {
							obj.v["bg"] = "#f7f7f8";
						}
						NewArr.push(obj);

						return {
							RoutineInspectionDeDeID: item.RoutineInspectionDeDeID,
							value: item.value,
							r: rowIndex,
							c: index + that.AllowableScope.c + 1,
						}
					})

					// 获取实测值最新数据
					let NewTime = '';
					NewTime = APP.GetNewTime(data.InspectionTime);


					let lastData = [{
							"r": rowIndex,
							"c": that.AllowableScope.c + that.MeasuredMaxLength + 1,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": data.FResult, //内容的原始值
								"m": data.FResultID, //内容的显示值
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": data.FResultID === -1 ? '#999' : data.FResultID === 1 ? '#05bd40' : '#f00',
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 1, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						}, {
							"r": rowIndex,
							"c": that.AllowableScope.c + that.MeasuredMaxLength + 2,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": data.FRemarks, //内容的原始值
								"m": data.FRemarks, //内容的显示值
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						},
						{
							"r": rowIndex,
							"c": that.AllowableScope.c + that.MeasuredMaxLength + 3,
							"v": {
								"ct": { //单元格值格式
									"fa": "General", //格式名称为自动格式
									"t": "n" //格式类型为数字类型
								},
								"v": NewTime, //内容的原始值
								"m": NewTime, //内容的显示值
								// "bg": "#eeeff1", //背景为 "#eeeff1"
								"ff": 1, // 字体为 "Arial"
								"fc": "#333", //字体颜色为 "#333"
								"bl": 0, //字体加粗
								"fs": 9, //字体大小为 9px
								"ht": 0, //水平居中
								"vt": 0, //垂直居中
								"tb": 2, //文本自动换行
							}
						},
					]

					NewArr.push(...lastData);

					return NewArr

				},
				ChangeIptFocus() {
					var that = this;
					// 如果当前是实测值,判断单元格设备是否与外部设备一致
					if (that.Choice_In_ListInfo.IsMeasured) {
						// // 获取选中输入框位置对应的对象数据
						let Benchmark = vm.ChoiceRowInfo.Benchmark;

						// // 获取选中单元格所需的测量设备
						if (Benchmark) {
							console.log(Benchmark)
							if (Benchmark.indexOf('|') == -1) {
								vm.DeviceInfo.NeedDevice = Benchmark;
							} else {
								vm.DeviceInfo.NeedDevice = Benchmark.slice(0, Benchmark.indexOf('|'));
							}

							// console.log(Benchmark.indexOf(vm.DeviceInfo.DeviceModel) != -1);
							// // 判断选中单元格所需测量工具，是否与外部协议工具一致，一致则聚焦输入框，反之不聚焦
							// if (Benchmark.indexOf(vm.DeviceInfo.DeviceModel) != -1) {

							// 	// 显示输入框
							// 	// vm.showEditWindow = true
							// 	vm.FromDevice = true;
							// 	// 聚焦必须要时间，否则无法聚焦
							// 	setTimeout(function() {
							// 		vm.$refs.editKeyControl.querySelector('input').focus();
							// 	}, 50);
							// } else {
							// 	vm.showEditWindow = false;
							// 	vm.FromDevice = false;
							// 	setTimeout(function() {
							// 		vm.$refs.editKeyControl.querySelector('input').blur();
							// 	}, 50);
							// }
						} else {
							vm.showEditWindow = false;
							setTimeout(function() {
								vm.$refs.editKeyControl.querySelector('input').blur();
							}, 50);
						}
					}
				},
				ExcleInit(rowNums, colNums, cellData, dataVerfications) { // 初始化设置
					var that = this;

					var options = {
						container: 'luckysheet', //luckysheet is the container id
						title: 'Luckysheet Demo', // 设定表格名称
						lang: 'zh', // 设定表格语言
						showtoolbar: false,
						showinfobar: false,
						showsheetbar: false,
						sheetFormulaBar: false,
						showstatisticBar: true, // 缩放按钮
						showcolumnbar: false,
						enableAddRow: false,
						enableAddBackTop: false,
						keyboardenable: false, // 禁止键盘弹起选中单元格
						editable: false, // 设置为只读模式
						rowHeaderWidth: 0,
						columnHeaderHeight: 0,
						rowTitleCellRenderAfter: false,
						columnTitleCellRenderAfter: false,
						data: [{
							"name": "检验", //工作表名称
							"color": "", //工作表颜色
							"index": 0, //工作表索引
							"status": 1, //激活状态
							"order": 0, //工作表的下标
							"hide": 0, //是否隐藏
							// "row": rowNums, //行数
							"column": that.AllowableScope["c"] + that.MeasuredMaxLength + 3, //列数
							"defaultRowHeight": 19, //自定义行高
							"defaultColWidth": 150, //自定义列宽
							"celldata": cellData,
							"config": {
								"merge": {}, //合并单元格
								"borderType": "border-all",
								"rowlen": {}, //表格行高
								"columnlen": {
									"0": 160,
									"1": 60,
									"2": 73,
									"3": 100,
									"4": 150,
								}, //表格列宽
								"rowhidden": {}, //隐藏行
								"colhidden": {}, //隐藏列
								"borderInfo": {
									"range": "0:100",
									"value": "1px solid #000000"
								}, //边框
								"authority": {}, //工作表保护

							},
							"scrollLeft": 0, //左右滚动条位置
							"scrollTop": 0, //上下滚动条位置
							"luckysheet_select_save": [], //选中的区域
							"calcChain": [], //公式链
							"isPivotTable": false, //是否数据透视表
							"pivotTable": {}, //数据透视表设置
							"filter_select": {}, //筛选范围
							"filter": null, //筛选配置
							"luckysheet_alternateformat_save": [], //交替颜色
							"luckysheet_alternateformat_save_modelCustom": [], //自定义交替颜色	
							"luckysheet_conditionformat_save": {}, //条件格式
							"zoomRatio": 1, // 缩放比例
							"image": [], //图片
							"showGridLines": 1, //是否显示网格线
							"dataVerification": dataVerfications, //数据验证配置
							"frozen": {
								type: 'rangeBoth',
								range: {
									row_focus: that.AllowableScope.r,
									column_focus: that.AllowableScope.c,
								}
							}
						}],
						hook: {
							rangeSelect(sheet, range) { // 框选或者设置选区后触发,(点击单元格)
								// 提取选中单元格的行和列信息
								let ranged = {
									r: range[0].row[0],
									c: range[0].column[0],
								};
								// 检验结果列
								let RestleColumn = +that.HeadLeftData.length + +that.MeasuredMaxLength;

								// vm.editKeyword = '';
								$('#autoInput').val("")
								/*  
									条件：选中的单元格是第一列的复选框单元格：r > 0, c = 0;
									1、点击最左侧复选框，改变显示状态
									2、当复选框有勾选的，显示删除按钮
								 */
								vm.editRange = range;
								if (range[0].column_focus == 0 && range[0].row_focus > 0) {
									for (let i = 0; i < that.SheetListData.length; i++) {
										if (range[0].row_focus >= that.SheetListData[i].range[0] && range[0]
											.row_focus <= that.SheetListData[i].range[1]) {

											for (let j = 0; j < that.SheetListData[i].FQCItems.length; j++) {
												if (that.SheetListData[i].FQCItems[j].rowIndex == range[0]
													.row_focus) {
													// 改变数组中的状态
													that.SheetListData[i].FQCItems[j].checked = !that
														.SheetListData[i].FQCItems[j].checked;
													// 改变表格中的状态
													luckysheet.setDataVerification({
														type: 'checkbox',
														type2: null,
														value1: that.SheetListData[i].FQCItems[j]
															.ProductName,
														value2: that.SheetListData[i].FQCItems[j]
															.ProductName,
														checked: that.SheetListData[i].FQCItems[j].checked
													}, {
														range: that.indexToCell([range[0].row_focus, 0])
													});

													// 这一段，防止点击自身不触发的问题。必须加定时器
													setTimeout(() => {
														luckysheet.setRangeShow('A1:A1', {
															show: false
														});
													}, 5)
													break;
												}
											}

										}
									}
								} else if (range[0].row_focus > 0 && range[0].row_focus <= that.TheMaxRow) {

									if (range[0].column_focus == RestleColumn) {
										// 点击项是检验结果列
										vm.showResult = true;
										var cellValue = luckysheet.getCellValue(range[0].row[0], range[0]
											.column[0]);
										vm.isJYResult = cellValue;
									}


									/**
									 * 目的：点击行，获取该行信息
									 */
									if (range[0].column_focus > 0) { // 如果点的不是第一列
										that.RowInfo.ShowRowInfo = true;
									} else {
										that.RowInfo.ShowRowInfo = false;
									}
									// 点击项是实测值，还缺少一个行限制
									that.Choice_In_ListInfo.ShowCJQty = true;

									// 获取点击项的行信息
									for (let [index, item] of that.SheetListData.entries()) {
										// 判断是在哪一条数据下,找到符合条件的，跳出循环
										let isTrue = false;
										if (range[0].row_focus >= item.range[0] && range[0].row_focus <= item
											.range[1]) {
											for (let [ind, ReItem] of item.FQCItems.entries()) {
												// 确定选中行信息
												if (ReItem.rowIndex == range[0].row_focus) {
													that.Choice_In_ListInfo.RowCJQty = ReItem.CJQty;
													that.Choice_In_ListInfo.RowActualCJQty = ReItem.MeasuredValue
														.length;
													vm.isJYResult = ReItem.FResult;

													// Start 这个用于展示到行明细弹层的实测值数据里
													let TheValueData = JSON.parse(JSON.stringify(ReItem
														.MeasuredValue));
													TheValueData = TheValueData.slice(0, ReItem.CJQty);
													vm.TheValueData = TheValueData;
													// End

													that.ChoiceRowInfo = ReItem;
													// 记录选中行在数组中的位置，便于快速查找
													that.Choice_In_ListInfo.FirstIndex = index;
													that.Choice_In_ListInfo.FQCItemsIndex = ind;

													// 如果选中的实测值位置，不在范围内，不允许填值，显示可不测量 
													let AllowEdit = range[0].column_focus - 4;
													if (range[0].column_focus >= 5 && range[0].column_focus <
														RestleColumn && range[0].row_focus > 0) {
														if (ReItem.CJQty >= AllowEdit) { // 确保在实测值范围
															console.log(ReItem.Benchmark);
															// 记录选中行的检验方式
															if (!APP.isEmpty(ReItem.Benchmark)) {
																if (ReItem.Benchmark.indexOf('|') == -1) {
																	that.Choice_In_ListInfo.Benchmark = ReItem
																		.Benchmark;
																} else {
																	that.Choice_In_ListInfo.Benchmark = ReItem
																		.Benchmark.slice(0, ReItem.Benchmark
																			.indexOf('|'));
																}
																// 记录是否是实测值
																that.Choice_In_ListInfo.IsMeasured = true;
															} else {
																that.Choice_In_ListInfo.Benchmark = '不可测量';
																that.Choice_In_ListInfo.IsMeasured = false;
															}
														} else {
															that.Choice_In_ListInfo.Benchmark = '不可测量';
															that.Choice_In_ListInfo.IsMeasured = false;
														}
													} else {
														that.Choice_In_ListInfo.Benchmark = '不可测量';
														that.Choice_In_ListInfo.IsMeasured = false;
													}

													isTrue = true;
													break;
												};
											};
										};
										if (isTrue) {
											break;
										}
									};

								} else {
									vm.editRange = [];
									that.RowInfo.ShowRowInfo = false; // 关闭详情弹层
									that.Choice_In_ListInfo.Benchmark = '不可测量';
									that.Choice_In_ListInfo.IsMeasured = false;
									that.Choice_In_ListInfo.ShowCJQty = false;
								}

								// 判断是否聚焦输入框
								that.ChangeIptFocus()
							},
							cellEditBefore: (range) => { // 进入单元格编辑模式之前触发
								// 提取选中单元格的行和列信息
								let ranged = {
									r: range[0].row_focus,
									c: range[0].column_focus,
								};


								// 检验结果列
								let RestleColumn = +that.HeadLeftData.length + +that.MeasuredMaxLength;
								// 1、如果选中的单元格不是检验行，直接return
								if (!vm.Choice_In_ListInfo.ShowCJQty) {
									throw '只读，回传报错'
									return
								}

								// 2、如果在实测值范围内，选中的是不可测量的，直接return
								if (range[0].column_focus > that.HeadLeftData.length && range[0]
									.column_focus < RestleColumn) {
									if (!vm.Choice_In_ListInfo.IsMeasured) {
										throw '只读，回传报错'
										return
									}
								}



								//判定该单元格是否为可编辑的单元格
								var ChoiceEditCell_c = range[0].column_focus;
								var ChoiceEditCell_r = range[0].row_focus;
								// 如果双击的是可编辑单元格 
								if (ChoiceEditCell_r > this.AllowableScope.r && ChoiceEditCell_c > this
									.AllowableScope.c && ChoiceEditCell_c != RestleColumn &&
									ChoiceEditCell_c != RestleColumn + 2) {
									// 可弹起软键盘
									vm.InputFocus = 'text'

									// 获取选中单元格的位置和内容
									// 先关闭回显到输入框的数据
									// vm.editKeyword = luckysheet.getCellValue(range[0].row_focus, range[0]
									// 	.column_focus);
									setTimeout(function() {
										vm.showEditWindow = true;
										// 获取选中单元格的位置和内容
										const cellValue = luckysheet.getCellValue(ranged.r, ranged.c);
										// 给输入框赋值
										$('#autoInput').val(cellValue);
										// vm.$refs.editKeyControl.querySelector('input').focus();
									}, 50);
								} else {
									vm.showEditWindow = false;
									// vm.editKeyword = '';
									$('#autoInput').val("")
								}
								// AllowableScope.r
								// AllowableScope.c

								throw '只读，回传报错'
							},
							rowTitleCellRenderBefore: function(rowNum, position, ctx) {
								return false;
							},
							columnTitleCellRenderBefore: function() {
								return false;
							},
							cellMousedownBefore(cell, position) {
								vm.IsWhere = vm.indexToCell([position.r, position.c])
								luckysheet.setRangeShow(vm.IsWhere + ':' + vm.IsWhere);
								return false;
							},
							cellUpdated(r, c, oldValue, newValue, isRefresh) { // 更新这个单元格后触发

							}
						}
					}

					luckysheet.create(options)


					// setTimeout(() => {

					// }, 1000)

				},
				BlurSearch() { // 赋值输入框失焦
					vm.InputFocus = 'none';
					setTimeout(() => {
						// 隐藏输入框
						vm.showEditWindow = false;
					}, 30)
				},
				submitKeyword(data) { // 输入框确认赋值


					vm.InputFocus = 'none';
					const NewData = [
						[{
							"m": vm.NumberMapBack($('#autoInput').val()), // 显示值
							"v": vm.NumberMapBack($('#autoInput').val()), // 原始值
							"ht": 0, // 水平对齐 0 居中、1 左、2右	
							"vt": 0, // 垂直对齐 0 中间、1 上、2下
							"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行
						}]
					];

					let ranged = {
						r: vm.editRange[0].row_focus,
						c: vm.editRange[0].column_focus,
					};
					// 转换单元格坐标格式
					let IsWhere = vm.indexToCell([ranged.r, ranged.c]);

					//回写单元格
					luckysheet.setRangeValue(NewData, {
						range: IsWhere + ':' + IsWhere
					});

					var CellWhere = vm.cellToIndex(vm.IsWhere);
					var TheIndex = null;
					// 缺少与数组数据匹配的步骤
					// vm.SheetListData[vm.Choice_In_ListInfo.FirstIndex].CJQty // 抽检数量
					let Index = vm.Choice_In_ListInfo.FirstIndex,
						ind = vm.Choice_In_ListInfo.FQCItemsIndex;

					TheIndex = CellWhere[1] - 4 - 1;

					// 加一层判断，是实测值，才会触发
					if (vm.Choice_In_ListInfo.Benchmark != '不可测量') {
						// 更改对应的 实测值、最新修改时间
						// vm.SheetListData[Index].FQCItems[ind].value[TheIndex] = data;
						vm.SheetListData[Index].FQCItems[ind].MeasuredValue[TheIndex].value = data;
						vm.SheetListData[Index].FQCItems[ind].NewTime = APP.getFormatDate2();
						vm.SheetListData[Index].FQCItems[ind].InspectionTime[0] = APP.getFormatDate2();

						let TimeColumn = +vm.HeadLeftData.length + +vm.MeasuredMaxLength + 2;
						let theRowTimeWhere = vm.indexToCell([CellWhere[0], TimeColumn]);
						let times = APP.getFormatDate2();
						const NewTime = [
							[{
								"m": times, // 显示值
								"v": times, // 原始值
								"ht": 0, // 水平对齐 0 居中、1 左、2右	
								"vt": 0, // 垂直对齐 0 中间、1 上、2下
								"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行
							}]
						];
						luckysheet.setRangeValue(NewTime, {
							range: theRowTimeWhere + ':' + theRowTimeWhere
						});
					} else {
						// 目前只有备注一栏是需要输入的，所以不做判断
						vm.SheetListData[Index].FQCItems[ind].FRemarks = data;

					}

					// 赋值时间

					// 检验时间列
					// let TimeColumn = +vm.HeadLeftData.length + +vm.MeasuredMaxLength + 2;
					// let theRowTimeWhere = vm.indexToCell([CellWhere[0], TimeColumn]);
					// let times = APP.getFormatDate2();
					// const NewTime = [
					// 	[{
					// 		"m": times, // 显示值
					// 		"v": times, // 原始值
					// 		"ht": 0, // 水平对齐 0 居中、1 左、2右	
					// 		"vt": 0, // 垂直对齐 0 中间、1 上、2下
					// 		"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行
					// 	}]
					// ];
					// luckysheet.setRangeValue(NewTime, {
					// 	range: theRowTimeWhere + ':' + theRowTimeWhere
					// });

					TheValueData = JSON.parse(JSON.stringify(vm.ChoiceRowInfo.MeasuredValue));

					CJQty = vm.Choice_In_ListInfo.RowActualCJQty;

					TheValueData = TheValueData.slice(0, CJQty)

					vm.TheValueData = TheValueData;
					console.log(vm.FromDevice);
					if (vm.FromDevice) { // 如果是从设备读取的，获取下一个
						vm.ChoiceCell(Index, ind, TheIndex)
					}

					// vm.FromDevice = false;

				},
				ChoiceCell(Index, ind, TheIndex) { // 选择下一个单元格
					let FilterData = [];

					for (let [index, item] of vm.SheetListData.entries()) {
						if (index < Index) { // 如果当前遍历的一级索引小于当选中项的，直接跳出当前循环
							continue;
						} else if (index == Index) { // 如果位置相同，把当前选中项索引在数组中需要的数据push进去

							for (let [FOCItemIndex, ReItem] of item.FQCItems.entries()) {
								let CJNum = 0;

								// if (item.CJQty > 10) {
								// 	CJNum = 10;
								// } else {
								CJNum = item.CJQty;
								// }
								// 记录可检验剩余数量
								let Remainder = CJNum - TheIndex - 1;
								if (FOCItemIndex < ind) { // 列表遍历的索引 小于 选中项所在索引
									continue;
								} else if (FOCItemIndex == ind) {
									// TheIndex
									if (Remainder == 0) { // 如果当前项已是当前行的最后一项，跳出循环，去下一行
										continue;
									} else {
										let TheFilterData = ReItem.MeasuredValue.slice(TheIndex + 1);
										FilterData.push(...TheFilterData)
									}
								} else {
									let CJNum = 0;

									CJNum = item.CJQty;

									let TheFilterData = ReItem.MeasuredValue.slice(0, CJNum);
									FilterData.push(...TheFilterData)
								}

							}
						} else {
							for (let [FOCItemIndex, ReItem] of item.FQCItems.entries()) {
								let CJNum = 0;

								CJNum = item.CJQty;

								let TheFilterData = ReItem.MeasuredValue.slice(0, CJNum);
								FilterData.push(...TheFilterData);
							}
						}

					}

					if (FilterData.length) {
						let IsWhere = vm.indexToCell([FilterData[0].r, FilterData[0].c])
						luckysheet.setRangeShow(IsWhere + ':' + IsWhere);
						vm.IsWhere = IsWhere
					} else {
						console.log('结束')
						vm.showEditWindow = false;
					}
				},

				// 公共方法
				cellToIndex(cell) { // 单元格转换  将 A1 转换成 [0,0]
					return APP.excelAddressToArrayIndex(cell)
				},
				indexToCell(index) { // 将 [0,0] 转换成 A1  [26,0] => AA1
					const column = APP.createCellPos(index[1]); // 将列索引转换为列字母，0对应A，1对应B，以此类推
					const row = index[0] + 1; // 将行索引转换为行数字，加上1是因为单元格标识从1开始
					return column + row;
				},

				// 通讯方法
				SetServiceIP(IP) { // 从外部获取账套IP地址
					var that = this
					let data = JSON.parse(IP);
					APP.serverIP(data.serverIP);
					APP.IPAgreement(data.IPAgreement);
					setTimeout(() => {
						that.getListFun(0)
						that.getListFun(1)
					}, 300)
				},
				GetUserInfo(data) { // 从外部获取获取用户信息
					var that = this;
					console.log(data);
					that.UserInfo = JSON.parse(data);
					APP.getUserInfo(JSON.parse(data));
					// that.UserInfo = data;
					// APP.getUserInfo(data);
				},
				GetDeviceStatus(data) { // 获取设备连接状态
					vm.deviceStatus = JSON.parse(data);
				},
				NumberMapBack(data) {
					if (data) {
						return data.replace(/。/, '.', 1);
					}
					return '';
				},
				// 外部调用内部方法
				GetBtnPermission(data) {
					console.log(JSON.parse(data))
					this.BtnApprove = JSON.parse(data);
				},
				ApproveBack(str) {
					let that = this;
					let Type = that.BtnApprove.some(item => {
						return item.MenuName == str
					})

					return Type;
				},
				GetDeviceName(val) { // 从外部获取选中协议的 协议类型 和 设备类型
					if (val) {
						let data = JSON.parse(val)
						this.DeviceInfo.Communication = data.Communication; // 协议类型
						if (data.Communication == 'HID') {
							this.DeviceInfo.ShowDeviceType = false;
						} else {
							this.DeviceInfo.ShowDeviceType = true;
						};

						this.DeviceInfo.DeviceModel = data.DeviceName; // 设备类型
					}
				},


				closeJYResult() { // 关闭检验结果弹层
					var that = this;
					// 检验结果列
					let RestleColumn = +that.HeadLeftData.length + +that.MeasuredMaxLength;
					const NewData = [
						[{
							"m": vm.isJYResult, // 显示值
							"v": vm.isJYResult, // 原始值
							"ht": 1, // 水平对齐 0 居中、1 左、2右	
							"vt": 0, // 垂直对齐 0 中间、1 上、2下
							"tb": 2, // 文本换行 0 截断、1溢出、2 自动换行 
							"fc": (vm.isJYResult === "合格" ? "#07d348" : (vm.isJYResult === "不合格" ? "#f00" :
								"#999"))
						}]
					];
					// 因为我有一个明细弹层，让弹层也能改变结果，所以，选中的IsWhere要改一下
					let Range = vm.cellToIndex(vm.IsWhere);

					let TheWhere = vm.indexToCell([Range[0], RestleColumn]);

					luckysheet.setRangeValue(NewData, {
						range: TheWhere + ':' + TheWhere
					});

					if (vm.isJYResult == "合格") {
						luckysheet.setDataVerification({
							type: 'checkbox',
							type2: null,
							value1: '合格',
							value2: '合格',
							checked: true
						}, {
							range: TheWhere
						});
					} else if (vm.isJYResult == "不合格") {
						luckysheet.setDataVerification({
							type: 'checkbox',
							type2: null,
							value1: '不合格',
							value2: '不合格',
							checked: false
						}, {
							range: TheWhere
						});
					} else if (vm.isJYResult == "忽略") {
						luckysheet.setDataVerification({
							type: 'checkbox',
							type2: null,
							value1: '忽略',
							value2: '忽略',
							checked: false
						}, {
							range: TheWhere
						});
					}
					if (Range[1] == RestleColumn) { // luckysheet 选中的是检验列
						luckysheet.setRangeShow('A1:A1', {
							show: false
						});
					}

					let Index = vm.Choice_In_ListInfo.FirstIndex,
						ind = vm.Choice_In_ListInfo.FQCItemsIndex;

					let TheRowResult = vm.isJYResult === "合格" ? 1 : (vm.isJYResult === "不合格" ? 2 : -1);

					vm.SheetListData[Index].FQCItems[ind].FResult = vm.isJYResult;
					vm.SheetListData[Index].FQCItems[ind].FResultID = TheRowResult;

				},
				RefreshTables() { // 刷新表格弹层
					vm.getListFun(0)
					vm.getListFun(1)
					// vm.getListFun(2)
				},
				onClickLeft() {
					vant.Dialog.confirm({
						title: '提示',
						message: '是否确认退出？',
					}).then(() => {
						vm.GoBack()
					}).catch(() => {

					});
				},
				GoBack() {
					setTimeout(() => {
						// uni.navigateBack()
						let Obj = {
							action: 'GoBack',
							param: {
								url: '',
								title: '',
							},
						}

						uni.postMessage({
							data: Obj
						});
					}, 30)
				},
			}
		})
	</script>
</html>